<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>（出入库调度）制定入库单</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/bootstraptable/bootstrap-table.css" rel="stylesheet">
</head>
<body>
<div style="color: #0e9aef;">您正在做的业务是：库存管理--出入库调度管理--制定入库单</div>
<div style="margin-top: 10px;">符合条件的入库单总数：<span id="eligible_total_span"></span>例</div>
<div class="container">
    <form class="form-horizontal" id="formulate_warehousing_form">
        <div class="form-group">
            <div class="col-md-5">
                <label class="control-label col-md-4">请选择入库理由</label>
                <div class="col-md-8">
                    <select class="form-control" name="search_reson" id="search_reson">
                        <option value="">--请选择--</option>
                        <option value="R001-2">库存初始</option>
                        <option value="R001-1">生产入库</option>
                        <option value="R001-3">赠送</option>
                        <option value="R001-4">内部归还</option>
                        <option value="R001-5">其他归还</option>
                    </select>
                </div>
            </div>
            <div class="col-md-5">
                <label class="col-md-4 control-label">请输入登记时间</label>
                <div class="col-md-4">
                    <input type="date" name="search_regtime1" id="search_regtime1" class="form-control">
                </div>
                <div class="col-md-4">
                    <input type="date" name="search_regtime2" id="search_regtime2" class="form-control">
                </div>
            </div>
            <div class="col-md-offset-2">
                <input type="button" class="btn btn-default" value="查询" id="search_btn">
            </div>
        </div>
    </form>
</div>

<table id="formulate_warehousing_table"></table>


<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="/js/hAdmin.js?v=4.1.0"></script>
<script src="/js/currentTime.js"></script>

<!-- 第三方插件 -->
<script src="/js/plugins/pace/pace.min.js"></script>

<!--BootstrapTable-->
<script src="/bootstraptable/bootstrap-table.min.js"></script>
<script src="/bootstraptable/locale/bootstrap-table-zh-CN.min.js"></script>

<script>
    $(function (){
        setTimeout(function (){
            let num=$("#formulate_warehousing_table").bootstrapTable("getOptions").totalRows
            $("#eligible_total_span").html(num)
        },500)

        $("#formulate_warehousing_table").bootstrapTable({
            method: "post",
            contentType: "application/x-www-form-urlencoded",
            url: "/storage/gather/queryStorageAuditPass",
            // 数据行交替样式
            striped: true,
            // 是否是服务器端分页：server表示服务器端，client表示前端分页
            sidePagination: 'server',
            //初始化加载第一页
            pageNumber: 1,
            //是否分页
            pagination: true,
            // 单页记录数，页大小
            pageSize: 5,
            // 分页列表
            pageList: [8, 10, 20],
            // 请求参数
            queryParams: function (params) {
                let obj = {
                    // params.limit获取组件中的页大小
                    // params.offset获取请求数据的起始索引
                    pageSize: params.limit,
                    pageNo: (params.offset / params.limit) + 1,

                    // 查询表单的数据
                    search_reson: $("#formulate_warehousing_form #search_reson").val(),
                    search_regtime1: $("#formulate_warehousing_form #search_regtime1").val(),
                    search_regtime2: $("#formulate_warehousing_form #search_regtime2").val(),
                }
                return obj;
            },
            // 表格列标题
            columns: [{
                title: "入库单编号",
                field: "gatherId"
            }, {
                title: "入库理由",
                field: "reason",
                formatter: function (value, row, index) {
                    if (value == "R001-1") {
                        return "生产入库"
                    } else if (value == "R001-2") {
                        return "库存初始"
                    } else if (value == "R001-3") {
                        return "赠送"
                    } else if (value == "R001-4") {
                        return "内部归还"
                    } else {
                        return "其他归还"
                    }
                }
            }, {
                title: "入库详细理由",
                field: "reasonexact"
            },{
                title: "登记时间",
                field: "registerTime",
                formatter: function (value, row, index) {
                    return formater(value)
                }
            }, {
                title: "总件数",
                field: "amountSum"
            }, {
                title: "总金额",
                field: "costPriceSum",
            },{
                title: "入库调度",
                formatter:function (value,row,index){
                    return `<a href="javascript:getById(${row.id})">入库调度</a>`
                }
            }]
        })

        $("#formulate_warehousing_form #search_btn").click(function (){
            $("#formulate_warehousing_table").bootstrapTable("refresh")
        })
    })

    function getById(id){
        localStorage.setItem("id",id)
        window.location="formulate_warehousingByIdUI"
    }
</script>
</body>
</html>